package com.john.test.http.proxy.validator;

import com.john.test.http.proxy.data.ProxyItem;
import com.john.http.core.util.ThreadUtil;
import com.john.test.http.proxy.validator.data.TestSite;
import com.john.test.http.proxy.validator.data.ValidatorConfig;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.List;
import java.util.concurrent.BlockingQueue;

/**
 * 〈一句话功能简述〉<br/>
 * 〈功能详细描述〉
 *
 * @author jiangguangtao on 2016/4/28.

 */
public class ProxyDispatcherThread implements Runnable {
    private static final Logger log = LoggerFactory.getLogger(ProxyDispatcherThread.class);
    private List<ProxyItem> proxyItemList;
    private BlockingQueue<ProxyItem> testedItemQueue;
    private List<TestSite> testSite;

    public ProxyDispatcherThread(List<ProxyItem> proxyItemList, BlockingQueue<ProxyItem> testedItemQueue, List<TestSite> testSite) {
        this.proxyItemList = proxyItemList;
        this.testedItemQueue = testedItemQueue;
        this.testSite = testSite;
    }

    @Override
    public void run() {
        for (ProxyItem proxyItem : proxyItemList) {
            ValidatorConfig vc = new ValidatorConfig(proxyItem, testSite, testedItemQueue);
            ProxyTesterRunner testerRunner = new ProxyTesterRunner(vc);
            ThreadUtil.execute(testerRunner);
        }
    }
}
